<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../plugins/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="../plugins/layui/css/myPage.css">
    <style>
        .layui-form-select dl{
            max-height: 100px; //原值为300，调节高度建议为50的倍数
        }
    </style>
</head>
<body  >
<div class="layui-container">


    <form class="layui-form">
        <div class="layui-row">
            <div class="layui-col-md12">

                <fieldset class="layui-elem-field" style="margin-top: 20px;">
                    <legend>新增用户</legend>


                    <div class="layui-form-item">

                        <div class="layui-inline">
                            <label class="layui-form-label"><span style="color: red;">*</span>用户名</label>
                            <div class="layui-input-inline" style="width: 150px;">
                                <input   type="text" name="yhm"  lay-verify="required" required   class="layui-input" id="yhm" >
                            </div>
                        </div>

                        <div class="layui-inline">
                            <label class="layui-form-label"><span style="color: red;">*</span>真实姓名</label>
                            <div class="layui-input-inline" style="width: 150px;">
                                <input   type="text" name="zsxm"  lay-verify="required" required   class="layui-input" id="zsxm" >
                            </div>
                        </div>


                        <div class="layui-inline">
                            <label class="layui-form-label" style="width: 70px;"><span style="color: red;">*</span>手机号</label>
                            <div class="layui-input-inline" style="width: 150px;">
                                <input   type="text" name="sjh"  lay-verify="required" required   class="layui-input" id="sjh" >
                            </div>
                        </div>

                        <div class="layui-inline">
                            <label class="layui-form-label" style="width: 70px;"><span style="color: red;">*</span>所属部门</label>
                            <div class="layui-input-inline" style="width: 150px;">
                                <div class="layui-input-inline layui-form" style="width: 150px;">
                                    <input   type="hidden" name="bumenid" id="ssbmHid" >
                                    <select name="bumenid" lay-verify="required" required lay-search   id="ssbm"  lay-filter="ssbm"	 style="width: 150px;" >
                                        <option value="">请选择</option>
                                    </select>
                                </div>
                            </div>
                        </div>



                    </div>

                    <div class="layui-form-item">







                    </div>






                </fieldset>
            </div>
        </div>


        <button class="layui-btn layui-btn-normal"  lay-submit  lay-filter="new" style="width: 10%; position: absolute;left: 35%"  >立即提交</button>
        <button type="reset" class="layui-btn layui-btn-normal" style="width: 10%; position: absolute;left: 55%" >重置</button>
    </form>
</div>
<script src="../plugins/layui/layui.js"></script>
<script src="../js/config.js"></script>
<script src="../js/jquery.js"></script>
<script src="../js/jquery.md5.js"></script>
<script src="../js/tools.js"></script>

<script>
    layui.use(['table','form','layer','laydate','upload','jquery'],function () {
        var table = layui.table;
        var form = layui.form;
        var $ = layui.$;
        var jquery = layui.jQuery;
        var layer = layui.layer;
        var laydate = layui.laydate;
        var upload = layui.upload;

        //校验

        judgment($,'sjh',/^\d{11}$/,"请输入正确的手机号码");
        judgment($,'zsxm',/^[\u4E00-\u9FA5A-Za-z]+$/,"只能输入中文和英文");
//提交
        $("#modiInfo").on('click',function(){
            $("#huowu,#hwsl,#yunfei,#gls,#ydj").addClass("layui-disabled");
            $("#huowu,#hwsl,#yunfei,#gls,#ydj").attr("disabled",true);

            $("#modiSub").removeClass("layui-btn-disabled");
            $("#modiSub").removeAttr("disabled");

            $("#modiInfo").addClass("layui-btn-disabled");
            $("#modiInfo").attr("disabled",true);

            form.render('select');
        });


        laydate.render({
            elem: '#ddrq' //指定元素
            ,theme:'#0099FF'
            ,value: getFormatDate()
            ,type: 'date'
            ,format:'yyyy-MM-dd'
        });
//渲染客户

//部门渲染

            $.ajax({
                url: contextPath+"/deptlist" ,
                type: "GET",
                contentType:"application/json;charset=utf-8",
                dataType:"json",
                success: function(res) {
                    console.log(res);
                    for(var i in res.list){

                        var option = "<option value='"+ res.list[i].bumenid+ "'>"+res.list[i].name+"</option>";

                        $("#ssbm").append(option);
                    };
                    form.render('select');
                }
            });

//线路

//校验





        form.on('submit(new)', function(data){
            console.log(data.field);
            $("input").css("border","");
            $.ajax({
                url: contextPath+"/user",
                type: "POST",
                contentType:"application/json;charset=utf-8",
                data: JSON.stringify(data.field) ,
                dataType:"json",
                success: function(res) {
                    newSuccess($,layer,res)
                }
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });
    });

</script>
</body>
</html>